#include <fstream>
#include <vector>
#include <string>

using namespace std;

vector<string> board;
int	N, K;

bool RotateRow (int row)
{
	string& s = board[row];

	bool changed = false;

	for (int i=0; i<N-1; i++)
	{
		if (s[i] != '.' && s[i+1] == '.')
		{
			char tmp = s[i];
			s[i]= s[i+1];
			s[i+1] =tmp;
			changed = true;
		}
	}

	return changed;
}

void Rotate()
{
	for (int i=0; i<N; i++)
	{
		while (RotateRow (i))
		{
		}
	}
}

bool LineHas(int row, int col, char x, int rowStep, int colStep)
{
	int c =0;

	for (int i=0; i<=N; i++)
	{
		if (board[row][col] == x)
		{
			c ++;
			if (c>=K)
				return true;
		}
		else
		{
			c =0;
		}

		row += rowStep;
		col += colStep;

		if (row <0 || row >=N || col <0 || col >=N)
			break;
	}

	return false;
}


bool Any (char x)
{
	for (int i=0; i<N; i++)
	{
		if (LineHas(i, 0, x, 0, 1))
			return true;
		if (LineHas(0, i, x, 1, 0))
			return true;

		if (LineHas(i, 0, x, 1, 1))
			return true;
		if (LineHas(0, i, x, 1, 1))
			return true;

		if (LineHas(i, N-1, x, 1, -1))
			return true;
		if (LineHas(0, i, x, 1, -1))
			return true;
	}

	return false;
}

void RunA(const char* fnameIn, const char* fnameOut)
{
	ifstream fin(fnameIn);
	
	int caseCount;
	fin >> caseCount;

	ofstream fout(fnameOut);

	for (int i=0; i<caseCount; i++)
	{
		fin >> N >> K;

		board.clear();
		for (int n=0; n<N; n++)
		{
			string s;
			fin>>s;
			board.push_back(s);
		}

		Rotate();

		bool hasB = Any('B');
		bool hasR = Any('R');
		
		string r ="Neither";
		if (hasB)
			r = "Blue";
		if (hasR)
			r = "Red";
		if (hasB && hasR)
			r = "Both";

		fout<<"Case #"<<i+1<<": ";
		fout<< r;
		fout<<"\n";
	}
}

//int main(int argc, int argv[])
//{
//	RunA("A-small-practice.in", "A-small-practice.out");
//	RunA("A-large-practice.in", "A-large-practice.out");
//
//	return 0;
//}

